<?php

namespace common\models\datas;

use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
use yii\helpers\ArrayHelper;

/**
 * This is the model class for table "{{%customer_recharge}}".
 *
 * @property integer $id
 * @property integer $customer_id
 * @property string $total
 * @property string $operator
 * @property integer $operator_id
 * @property integer $cerated_at
 */
class CustomerRecharge extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%customer_recharge}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['customer_id', 'operator_id', 'created_at'], 'integer'],
            [['total'], 'number'],
            [['total'], 'required'],
            [['operator'], 'string', 'max' => 50],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('common', 'ID'),
            'customer_id' => Yii::t('common', '会员id'),
            'total' => Yii::t('common', '充值金额'),
            'operator' => Yii::t('common', '操作人'),
            'operator_id' => Yii::t('common', '操作人id'),
            'created_at' => Yii::t('common', '充值时间'),
        ];
    }

    public function behaviors()
    {
        return ArrayHelper::merge(parent::behaviors(), [
            [
                'class' => TimestampBehavior::className(),
                'attributes' => [
                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
                ],
            ],
        ]);
    }
}
